home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1998 August / macformat-066.iso / How-to's / Foreign Files / Creator Changer 2.8.4 / Code & Resource / Creator Changer.file.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-07-18  |  2.4 KB  |  97 lines  |  [TEXT/KAHL]

  1. /**********************************************************************
  2.  *    This file contains the functions which let the user determine 
  3.  *    which file to change the creator and/or file types.
  4.  **********************************************************************/
  5.  
  6. #include    "Creator Changer.h"
  7. #include    "Creator Changer.file.h"
  8.  
  9.  
  10. /**********************************************************************
  11.  *    Function Old_File(), this function calls the file to have the 
  12.  *    creator and / or file type changed.
  13.  **********************************************************************/
  14.  
  15. Boolean Pick_File(FSSpec *the_file_spec, FInfo *file_info, short get_icon)
  16.     {
  17.     
  18.     StandardFileReply    reply;
  19.     SFTypeList            my_types;
  20.     
  21.     StandardGetFile(NIL_PTR, -1, my_types, &reply);
  22.     if(!reply.sfGood) return(FALSE);
  23.     else
  24.         {
  25.         *the_file_spec=reply.sfFile;
  26.         FSpGetFInfo(the_file_spec, file_info);
  27.         return(TRUE);
  28.         }
  29.     
  30.     }
  31.  
  32.  
  33.  
  34.  
  35. /**********************************************************************
  36.  *    Function p_Str_Copy(), this function copies one pascal string to
  37.  *    another pascal string.
  38.  **********************************************************************/
  39.  
  40. void p_Str_Copy(StringPtr p1, StringPtr p2)
  41.     {
  42.     
  43.     register short len;
  44.     
  45.     len=*p2++=*p1++;
  46.     while(--len>=0) *p2++=*p1++;
  47.     
  48.     }
  49.  
  50.  
  51.  
  52. /**********************************************************************
  53.  *    Function Comp_The_String(), this function compares one pascal string 
  54.  *    to another pascal string.
  55.  **********************************************************************/
  56.  
  57. Boolean Comp_The_String(StringPtr p1, StringPtr p2)
  58.     {
  59.     
  60.     register short    len;
  61.     
  62.     len=*p2++=*p1++;
  63.     while(--len>=0) if(*p2++!=*p1++) return(BAD);
  64.     
  65.     return(GOOD);
  66.     
  67.     }
  68.  
  69.  
  70.  
  71. /**********************************************************************
  72.  *    Function Force_Finder_Update(), this function forces the Finder
  73.  *    to update the window in which the file was changed in.
  74.  **********************************************************************/
  75.  
  76. void Force_Finder_Update(FSSpec *the_file_spec)
  77.     {
  78.     
  79.     OSErr            error;
  80.     CInfoPBRec        lCBlk;
  81.     
  82.     if(the_file_spec->parID!=1) lCBlk.dirInfo.ioNamePtr=0L;
  83.     lCBlk.dirInfo.ioVRefNum=the_file_spec->vRefNum;
  84.     lCBlk.dirInfo.ioDrDirID=the_file_spec->parID;
  85.     lCBlk.dirInfo.ioFDirIndex=0;
  86.     lCBlk.dirInfo.ioCompletion=0;
  87.  
  88.     error=PBGetCatInfoSync(&lCBlk);
  89.     if(!error)
  90.         {
  91.         GetDateTime(&lCBlk.dirInfo.ioDrMdDat);
  92.         lCBlk.dirInfo.ioDrDirID=the_file_spec->parID;
  93.         PBSetCatInfoSync(&lCBlk);
  94.         FlushVol(NIL_PTR, the_file_spec->vRefNum);
  95.         }
  96.     
  97.     }